<template>
  <el-drawer title="货品批次" :visible.sync="visibility" size="39%">
    <el-table
      :data="list"
      align="left"
      height="500"
      highlight-current-row
    >
      <el-table-column label="批次号" prop="goodsBatchCode" width="100px" />
      <el-table-column label="浓度" prop="concentration" width="100px" />
      <el-table-column
        label="浓度单位"
        prop="concentrationUnit"
        width="100px"
      />
      <el-table-column label="生产日期" prop="productionDate" width="120px" />
      <el-table-column label="过期日期" prop="expirationDate" width="120px" />
      <el-table-column label="风险日期" prop="riskDate" width="120px" />
      <el-table-column label="冻结日期" prop="freezeDate" width="120px" />
    </el-table>
  </el-drawer>
</template>

<script>
import { listGoodsBatch } from '@/api/base/goodsBatch.js'

export default {
  props: {
    visible: {
      required: true,
      type: Boolean
    },
    currentRow: {
      type: Object,
      default: null
    }
  },
  data() {
    return {
      list: [],
      listQuery: {
        pageNumber: 1,
        pageIndex: 0,
        pageSize: 1000,
        goodsId: null
      }
    }
  },
  computed: {
    visibility: {
      get() {
        return this.visible
      },
      set(val) {
        this.$emit('update:visible', val)
      }
    }
  },
  watch: {
    currentRow(value) {
      if (value && value._action === 'batch') {
        this.listQuery.goodsId = value.goodsId
        listGoodsBatch(this.listQuery).then((response) => {
          this.list = response.data
        })
      }
    }
  },
  methods: {}
}
</script>

<style lang="scss" scoped>
</style>
